Linear algebra support + stricter name/arg validation - #87
Conversation
- Add min()/max() support in size expressions - Hoist/reuse Rf_asInteger() results to avoid repeated conversions in C - Add public-API tests via quick() and update translation snapshots
- Reject non-scalar vectors unless length equals matrix nrow - Add/adjust elementwise matrix tests for the stricter rule - Refresh translation snapshots
- Detect use of formal args without declare() - Add a public-API regression test
- Reject names that map to reserved identifiers - Snapshot full error messages for name clashes
- Preserve R names while fortranizing identifiers - Fix C bridge / closure codegen name resolution - Add public API tests for dotted args, locals, and loops
- Translate to Fortran epsilon() - Add quick() test and translation snapshot
- Compile svd() via LAPACK dgesdd() - Allow assigning svd() results and extracting components - Add quick() tests and translation snapshot
- Translate known singleton dims to slices/scalars - Add quick() tests and translation snapshots (NA/n dims)
- detect unguarded optional arg usage in closures - add regression test for NULL default without init
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #87 +/- ##
==========================================
- Coverage 92.79% 92.76% -0.04%
==========================================
Files 27 27
Lines 4888 5734 +846
==========================================
+ Hits 4536 5319 +783
- Misses 352 415 +63 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 89edddee36
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (var@is_arg && !var@modified) { | ||
| return(r) | ||
| return(scope_fortran_symbol(r, scope)) | ||
| } |
There was a problem hiding this comment.
Keep R-size symbols resolvable for dotted args
When r2size() sees an argument symbol it now returns scope_fortran_symbol() (e.g., foo.bar becomes foo_bar). That propagates into dimension expressions used by constructors/locals (e.g., out <- double(foo.bar)), so the return variable carries a size symbol foo_bar. The C bridge (dims2c_expr in c-wrapper.R) still resolves size symbols via get0() on the R name, so it can’t resolve foo_bar and will error (“could not resolve size: foo_bar”) or emit invalid C. This breaks compiled functions that size outputs from dotted arguments; either keep R symbols in r2size() or teach dims2c_expr/size resolution to map Fortranized names back to the scoped variable.
Useful? React with 👍 / 👎.
|
Pushed commit 3b7d555 adding public-API tests (all via New tests cover:
Also extended |
|
Addressed the review note about dotted args in size expressions.
Pushed in commit |
Also fix invalid subscript arity error formatting.
Motivation
This branch expands quickr’s ability to transpile “plain R” linear algebra code (the kind you’d typically write first, then optimize) while tightening correctness around symbol/argument handling. The intent is to make porting base-R numeric code to
quick()smoother, and to surface mismatches early with clear errors.User-facing changes
drop()for rank 0–2 inputs (including singleton matrices).svd()results usable via$d,$u, and$v(eithers <- svd(x); s$dorsvd(x)$d)..Machine$double.epsis supported.qr.solve()uses the LINPACK QR path for improved compatibility with base R.quick()(arguments, locals, loop variables), e.g.foo.bar.declare(type(arg = ...))now errors.nrowto match base R.NULLdefaults, with validation that optional arguments are initialized (via anis.null()branch) before use.Examples
svd()+.Machine$double.eps+qr.solve():Optional
NULLarguments in local closures (must initialize before use):Release notes
NEWS.mdis updated to reflect these user-facing changes.